<?php
declare (strict_types = 1);

namespace app\middleware;

class Token
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
//        $herd = $request->header();
//        if(empty($herd['time']) || empty($herd['token']) || empty($herd['user'])){
//            exit(json_encode([
//                'code'=> 500,
//                'message'=> '缺少加密参数：'.getRandomWord(10),
//                'data'=> null,
//                'type'=> '',
//            ]));
//            die();
//        }
//        $str = base64_decode($herd['user']);
//        $user = json_decode($str,true);
//
//        $role_key = config('app')['role_key'];
//        $key = md5($herd['time'].''.$role_key);
//        $tiken = md5($user['token'].$key);
//        if($tiken !== $herd['token']){
//            exit( ret_json_encode(500,'请重新登录',null,'error'));
//        }
        return $next($request);
    }
}

